<?php

namespace mpend\filters;

use Yii;
use yii\base\ActionEvent;
use yii\web\MethodNotAllowedHttpException;

/**
 * VerbFilter is an action filter that filters by HTTP request methods.
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class VerbFilter extends \yii\filters\VerbFilter {

    /**
     * @param ActionEvent $event
     * @return bool
     * @throws MethodNotAllowedHttpException when the request method is not allowed.
     */
    public function beforeAction($event) {
        if (Yii::$app->getRequest()->getIsOptions()) {
            return $event->isValid;
        }
        return parent::beforeAction($event);
    }

}
